package collect.map;

import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

public class TestTreeMap2 {
    public static void main(String[] args) {
        TreeMap<Student, String> ts = new TreeMap<>();
        Student stu1 = new Student("张三", 23, "男");
        Student stu2 = new Student("李四", 24, "男");
        Student stu3 = new Student("王五", 24, "男");
        Student stu4 = new Student("张三", 23, "男");
        ts.put(stu1, "重庆");
        ts.put(stu2, "陕西");
        ts.put(stu3, "贵州");
        ts.put(stu4, "云南");
        System.out.println(ts);
        Set<Map.Entry<Student, String>> entries = ts.entrySet();
        for (Map.Entry<Student, String> entry : entries) {
            System.out.println(entry.getKey() + "=" + entry.getValue());
        }
    }
}
